package websphinx.test;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import websphinx.Classifier;
import websphinx.MatchModel;
import websphinx.Matcher;
import websphinx.Page;

public class testClassifier implements Classifier {
	private FileWriter writer;
	private String script = "<div> <form> #divContent </form> </div>";

	public testClassifier(File file) throws IOException {
		writer = new FileWriter(file, true);
	}

	@Override
	public void classify(Page page) {
		Matcher matcher = new Matcher(page, script, MatchModel.TRYMATCH);
		boolean success = matcher.match();

		try {
			if (success)
				writer.write("success  ");
			else
				writer.write("fail     ");
			writer.write(page.getURL().toString() + "\n");
			writer.flush();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * Priority of this classifier.
	 */
	public static final float priority = 10.0F;

	@Override
	public float getPriority() {
		return priority;
	}

}

